import { ATeamCombat } from "GameLoop/WorldState/EntityManager/Entitys";
import { BinaryDecision } from "framework/FSM/DecisionTree/Decision";

/**
 * 是否是一字长蛇阵
*/
export class DecisionIsLineMove <T extends IStateArg<ATeamCombat,ITask>> extends BinaryDecision<T>
{


    public testValue(arg:T): boolean
    {

        const poss = _.map(arg.entity.creeps,item=>item.pos);
       // global.Log.Info(`队列移动:${JSON.stringify(poss)}`);
        for(let i=0;i<poss.length-1;i++)
        {
            // if(!poss[i] ||  !poss[i+1])
            // {
            //     return false;
            // }
            if(poss[i].roomName == poss[i+1].roomName)
            {
                if(poss[i].distance( poss[i+1])>1)
                {
                    // global.LogDebug(`队列移动队列被破坏:${JSON.stringify(poss)}`);
                    return false;
                }
            }
            else
            {
                if(poss[i].distance( poss[i+1])>2)
                {
                    return false;
                }
            }
        }
        return true;
        // return true;
    }

    value: any;


    public setValue(val: any)
    {
        this.value = val;
    }
}

